<?php
/**
 * Morningtime LatestReviews extension
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 *
 * @category   Morningtime
 * @package    Morningtime_LatestReviews
 * @copyright  Copyright (c) 2009 Morningtime Internet, http://www.morningtime.com
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
?>
<?php $_EM0029Setting=new EM_EM0029Settings_EM0029Settings();?>
<?php 
$_items 			= $this->getReviewsCollection(); 
$listingType 		= Mage::getStoreConfig('latestreviews/products/listing_type');
$_size				= intval(Mage::getStoreConfig('latestreviews/general/num_displayed_reviews'));
$_productCollection	= $this->getLoadedProductCollection();
$image=new EM_EM0029Settings_EM0029Settings ();
$w = $image->get_related_width();
?>
<?php if(!count($_items)): ?>
<div class="note-msg">
    <?php echo $this->__('There are no products matching the selection.') ?>
</div>
<?php else: ?>
<div class="block category-products">
<?php //echo $this->getToolbarHtml() ?>
<?php // Grid Mode ?>
<div class="block-title">
	<strong><span>Most Reviews</span></strong>
</div>
<div class="block-content">
<?php $_collectionSize = $_size; ?>
    <?php $_columnCount = 3; ?>
    <?php $i=0;$j=0; while ($_review = $_items->fetch()): ?>
	<?php if($j<3):?>
	
	<?php $_product = Mage::getModel('catalog/product')->load($_review['entity_pk_value']); ?>
        <?php if($i++%$_columnCount==0): ?>
        <ul class="mini-products-list">
         <?php endif; ?>
            <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
				<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" ><img <?php if($_EM0029Setting->get_related_bgcolor()) echo 'style="background-color:'.$_EM0029Setting->get_related_bgcolor().'"';?>src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_EM0029Setting->get_related_width(),$_EM0029Setting->get_related_height()); ?>" width="<?php echo $_EM0029Setting->get_related_width();?>" height="<?php echo $_EM0029Setting->get_related_height();?>" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
				<div class="product-details" style="margin-left:<?php echo $w ?>px;">				
                <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>"><?php echo $this->htmlEscape($_product->getName()) ?></a></h2>
				<?php $category = Mage::getModel('catalog/layer')->getCurrentCategory();?>
						<p><?php echo $category->getName();?></p>		
				<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
				</div>
            </li>
        <?php if($i%$_columnCount==0 || $i==$_collectionSize): ?>
        </ul>
        <?php endif; ?>
		<?php $j++;endif; ?>
    <?php endwhile ?>
</div>	
    <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
</div>
<?php //echo $this->getToolbarHtml() ?>
<?php endif; ?>

